<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        span{
            background:red;
            display: inline-block;
            padding:5px 10px;
            color:#fff;
            margin: 5px 0;
        }
        .changeColor span{
            background: green;
        }
        .changeLength span::after{
            content:"新文本";
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <div id="app">
        <h1>动态绑定css</h1>
        <h2>实例1</h2>
            <!-- <div 
                v-on:click="changeColor = !changeColor"
                v-bind:class="{changeColor:changeColor}" 
                >
                <span>
                    原文本
                </span>
            </div> -->
        <h2>实例2</h2>
            <button v-on:click="changeColor = !changeColor">改变颜色</button>
            <button @click="changeLength = !changeLength">改变长度</button>
            <button @click = "changeColor = !changeColor,changeLength = !changeLength">全部改变</button>
            <div v-bind:class="changeClasses">
                <span>
                    原文本
                </span>
            </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>
        new Vue({
            el:"#app",
            data:{
               changeColor:false,
               changeLength:false
            },
            methods:{
               
            },
            computed:{
                changeClasses:function(){
                    // 返回一个对象
                    return {
                        changeColor:this.changeColor,
                        changeLength:this.changeLength
                    }
                }
            }
            
        })
    </script>
</body>
</html>